<%@ page import="com.liu.lab06.pojo.Music" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: MyUser
  Date: 2025/3/13
  Time: 17:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<title>音乐管理系统</title>
<style type="text/css">
    table,th{
        border-spacing: 0em;
        margin-left: 1px;
        border: 1px solid #220808;
        border-collapse: collapse;
    }/*设置表格最外层边框实线*/
    th{
        color: white;
        background-color: rgba(38, 45, 59, 0.767);
    }
    td{
        border: 1px dashed;
    }/*设置单元格边框纵向虚线*/
    tr{
        vertical-align: top;
        border: 1px dashed;
    }/*设置单元格边框横向虚线*/
</style>
</head>
<body>
<!--输入关键词，点击提交按钮，跳转到ShowAllMusicsServlet文件-->
<form action="FindMusic" method="post">
<%--    歌名：<input type="text" name="musicname"/> <br/>--%>
    类型：<select name="category_id" size="1">
            <option value="流行">流行</option>
            <option value="古典">古典</option>
            <option value="经典">经典</option>
            <option value="国风">国风</option>
            <option value="儿童">儿童</option>
        </select><br/>
    <input type="submit" value="搜索"/>
</form>
&nbsp;
<form action="showAllMusics" method="get">
    <input type="submit" value="重置搜索"/>
</form>

<a href="toAddMusic">添加音乐</a>


<c:if test="${allMusics.size()>0}">
    <table width='50%' style='border-spacing: 0em;margin-left: 1px;border: 1px solid #220808;border-collapse: collapse;'>
        <tr>
            <th>id</th>
            <th>歌名</th>
            <th>演唱者</th>
            <th>排名</th>
            <th>分类</th>
            <th>编辑</th>
        </tr>
        <c:forEach items="${allMusics}" var="m" varStatus="s">
            <tr>
                <td><a href="musicDetails.jsp">${m.id}</a></td>
                <td>${m.musicname}</td>
                <td>${m.singer}</td>
                <td>${m.ranking}</td>
                <td>
<%--                        ${m.category_id}--%>
                        <c:choose>
                            <c:when test="${m.category_id == 1}">流行</c:when>
                            <c:when test="${m.category_id == 2}">古典</c:when>
                            <c:when test="${m.category_id == 3}">金典</c:when>
                            <c:when test="${m.category_id == 4}">国风</c:when>
                            <c:when test="${m.category_id == 5}">儿童</c:when>
                                <c:otherwise>其他</c:otherwise>
                        </c:choose>

                </td>
                <td>
                    <a href="toUpdateMusic?id=${m.id}">修改</a>
                    <a href="deleteMusic?id=${m.id}">删除</a>
                </td>
            </tr>
        </c:forEach>
    </table>
</c:if>
</body>
</html>
